home *** CD-ROM | disk | FTP | other *** search
- From: _GOYRA_@msn.com (David Byrden)
- Subject: RE: [Q] namespace #1
- Date: 9 Mar 96 22:14:19 -0800
- References: <4hf81b$aov@crl.crl.com>
- Message-ID: <00001a81+0000abf7@msn.com>
- Path: news.msn.com!msn.com
- Newsgroups: comp.lang.c++
- Organization: The Microsoft Network (msn.com)
-
-
- <<<<start quote<<<<<<<<<<<<<<<
-
- namespace foo
- {
- int Value = 43;
- };
-
- void main()
- {
- int Value = 65;
- using namespace foo;
- cout << Value << endl;
- }
-
- // QUESTIONS:
- // 1) Is this a valid program
- // 2) If so what is the expected output, if not what is the error
- // 3) What would be the result of using a using declaration instead
- // instead of a using directive
- //
- // NOTES:
- // 1) The Microsoft VC++ 4.0 compiler complains that Value is an
- // ambiguous symbol. Is this correct?
-
- >>>>>>>>>>>> end quote >>>>>>>>>>>>>>>>
-
-
- Dick;
-
- Names introduced by a using directive are found as if located in the
- smallest namespace which contains both the using-directive and the
- nominated namespace, i.e. they can be hidden by more-local names.
-
- The code is correct and Microsoft are wrong. The expected output is 65.
-
- A using declaration is subject to the normal rules for declarations,
- and therefore you would be declaring two Values in the same block,
- which is not allowed.
-
-
- David
-